<?php include("dbconfig.php"); ?>
<div class="widget w-box recents-widget">
	<h2 class="widget-title"><span><img src="images/announce.gif" width="180" height="90"></span></h2>	
	
	<ul class="prl-list-line">
		<?php
			$sql = "SELECT * FROM article WHERE fix_status = 1 AND fix_article_type = 12 ORDER BY inserted_date_time DESC LIMIT 5";
			$rsd = mysql_query($sql);
			while($row = mysql_fetch_array($rsd))
			{
		?>
				<li class="clearfix">
					<article class="prl-article">
					
		<?php
						$date = new DateTime($row['inserted_date_time']);
		?>
						<a href="single.php?id=<?=$row["article_id"]?>" class="prl-thumbnail floatleft" target="_blank">
		<?php
						if((bool)preg_match('#<img[^>]+src=[\'"]([^\'"]+)[\'"]#', html_entity_decode($row['description']), $matches))
						{
						   $imageFound = $matches[0];
						   $src = substr($imageFound, strpos($imageFound, "src"));
						}
						else
						{
						  $src = "src=\"images/default_image.png\"";
						}
		?>
						<img <?=$src?> width="60" height="60" alt="pataniforum"></a>
						<a class="recent-title" href="single.php?id=<?=$row["article_id"]?>" title="" target="_blank"><?=mb_substr(strip_tags(html_entity_decode($row['description'])),0,50,'UTF-8')?></a>
						<span class="prl-article-meta"><span><i class="fa fa-clock-o"></i><?=$date->format('d/m/Y H:i').",".iconv_substr($row["reference_st"],0,15,'UTF-8')?></span></span>
					</article>
				</li>
		<?php
			}
			mysql_close(); 
		?>
	</ul>
	<h5><span><a href="category.php?type=6">อ่านทั้งหมด</a></span></h5>
</div>	